package com.ts.mapper.achievement;

import com.ts.entity.AcademicConference;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AcademicConferenceMapper {

    /**
     * 存入一条学术会议成果数据并且主键返回
     */
    @Insert("INSERT INTO `tianshi-college-teacher-system-test`.ts_academic_conference " +
            "(conference_name, participants, conference_location," +
            " organizing_institution, conference_type, subject_category, start_time," +
            " end_time, submitted_paper, published_paper, remark," +
            " evidence_material, create_by, create_time, update_by," +
            " update_time) VALUES (" +
            " #{conferenceName}, #{participants}, #{conferenceLocation}," +
            " #{organizingInstitution}, #{conferenceType}, #{subjectCategory}, #{startTime}," +
            " #{endTime}, #{submittedPaper}, #{publishedPaper}, #{remark}," +
            " #{evidenceMaterial}, #{createBy}, #{createTime}, #{updateBy}," +
            " #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void save(AcademicConference academicConference);

    /**
     * 根据ID查询学术会议
     */
    @Select("SELECT * FROM `tianshi-college-teacher-system-test`.ts_academic_conference WHERE id = #{id}")
    AcademicConference getById(Long id);

    /**
     * 更新学术会议
     */
    @Update("UPDATE `tianshi-college-teacher-system-test`.ts_academic_conference SET " +
            "conference_name = #{conferenceName}, " +
            "participants = #{participants}, " +
            "conference_location = #{conferenceLocation}, " +
            "organizing_institution = #{organizingInstitution}, " +
            "conference_type = #{conferenceType}, " +
            "subject_category = #{subjectCategory}, " +
            "start_time = #{startTime}, " +
            "end_time = #{endTime}, " +
            "submitted_paper = #{submittedPaper}, " +
            "published_paper = #{publishedPaper}, " +
            "remark = #{remark}, " +
            "evidence_material = #{evidenceMaterial}, " +
            "update_by = #{updateBy}, " +
            "update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(AcademicConference academicConference);

    /**
     * 根据ID删除学术会议
     */
    @Delete("DELETE FROM `tianshi-college-teacher-system-test`.ts_academic_conference WHERE id = #{id}")
    void delete(Long id);
}